import axios from '@/libs/api.request'
import qs from 'qs';
export const login = ({ phone , code , token }) => {
    const data = {
        phone,
        code,
        token
    }
    return axios.request({
        url: '/user/login',
        params: data,
        method: 'post',
    })
}

export const checkPhoneExist = (phone) => {
    return axios.request({
        url: `/user/phone/${phone}/check`,
        method: 'get'
    })
}


export const getVerificationCode = (phone) => {
    return axios.request({
        url: `/user/phone/${phone}/code`,
        method: 'post',
        data: qs.stringify({phone})
    })
}


export const logout = () => {
    return axios.request({
        url: '/user/logout',
        method: 'put'
    })
}


export const revisePassword = (params) => {
    return axios.request({
        url: '/user/changePassword',
        method: 'put',
        data: qs.stringify(params)
    })

}


export const getCompanies = ()=>{
    return axios.request({
        url:'/user/company',
        method:'get',
        isLoading:0
    })
}

export const getAllAuth = (params)=>{
    return axios.request({
        url:'/user',
        method:'options',
        isLoading:0,
        params:{
            type:params
        }
    })
}

//用户基础接口  //新增用户
export const addUser = (params)=>{
    return axios.request({
        url:'/user',
        method:'post',
        data:qs.stringify(params)
    })
}



//获的护士长
export const getHeadNurse = (params)=>{
    return axios.request({
        url:'/user/headNurse',
        method:'get',
        params:params
    })
}

//获的护士
export const getNurse = (params)=>{
    return axios.request({
        url:'/user/nurse',
        method:'get',
        params:params
    })
}

// 获取人员的关联科室
export const getUserLinkBranch = (id)=>{
    return axios.request({
        url:`/user/branchUser/user/${id}`,
        method:'get',
        // params:params
    })
}
// 修改人员关联的科室信息
export const updateUserLinkBranch = (params)=>{
    return axios.request({
        url: `/user/branchUser/updateBranches`,
        method: 'put',
        data: qs.stringify(params)
    })
}

//获取用户列表
export const findUser = (params)=>{
    return axios.request({
        url:'/user/userList',
        method:'get',
        params:params
    })
}

//获取用户信息
export const getInfo = (userId)=>{
    return axios.request({
        url:`/user/${userId}/userInfo`,
        method:'get',
    })
}

export const getToken = (sid)=>{
    return axios.request({
        url:`/user/token`,
        method:'get',
        params:{
            sid:sid
        }
    })
}

